package com.robotic.videoAlarm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.robotic.common.annotation.Log;
import com.robotic.common.core.controller.BaseController;
import com.robotic.common.core.domain.AjaxResult;
import com.robotic.common.enums.BusinessType;
import com.robotic.videoAlarm.domain.VideoAlarmRecord;
import com.robotic.videoAlarm.service.IVideoAlarmRecordService;
import com.robotic.common.utils.poi.ExcelUtil;
import com.robotic.common.core.page.TableDataInfo;

/**
 * 异常行为报警管理Controller
 *
 * @author ruoyi
 * @date 2025-09-15
 */
@RestController
@RequestMapping("/admin/alarmRecord")
public class VideoAlarmRecordController extends BaseController
{
    @Autowired
    private IVideoAlarmRecordService videoAlarmRecordService;

    /**
     * 查询异常行为报警管理列表
     */
    @PreAuthorize("@ss.hasPermi('admin:alarmRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(VideoAlarmRecord videoAlarmRecord)
    {
        startPage();
        List<VideoAlarmRecord> list = videoAlarmRecordService.selectVideoAlarmRecordList(videoAlarmRecord);
        return getDataTable(list);
    }

    /**
     * 导出异常行为报警管理列表
     */
    @PreAuthorize("@ss.hasPermi('admin:alarmRecord:export')")
    @Log(title = "异常行为报警管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VideoAlarmRecord videoAlarmRecord)
    {
        List<VideoAlarmRecord> list = videoAlarmRecordService.selectVideoAlarmRecordList(videoAlarmRecord);
        ExcelUtil<VideoAlarmRecord> util = new ExcelUtil<VideoAlarmRecord>(VideoAlarmRecord.class);
        util.exportExcel(response, list, "异常行为报警管理数据");
    }

    /**
     * 获取异常行为报警管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('admin:alarmRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(videoAlarmRecordService.selectVideoAlarmRecordById(id));
    }

    /**
     * 新增异常行为报警管理
     */
    @PreAuthorize("@ss.hasPermi('admin:alarmRecord:add')")
    @Log(title = "异常行为报警管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VideoAlarmRecord videoAlarmRecord)
    {
        return toAjax(videoAlarmRecordService.insertVideoAlarmRecord(videoAlarmRecord));
    }

    /**
     * 修改异常行为报警管理
     */
    @PreAuthorize("@ss.hasPermi('admin:alarmRecord:edit')")
    @Log(title = "异常行为报警管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VideoAlarmRecord videoAlarmRecord)
    {
        return toAjax(videoAlarmRecordService.updateVideoAlarmRecord(videoAlarmRecord));
    }

    /**
     * 删除异常行为报警管理
     */
    @PreAuthorize("@ss.hasPermi('admin:alarmRecord:remove')")
    @Log(title = "异常行为报警管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(videoAlarmRecordService.deleteVideoAlarmRecordByIds(ids));
    }
}
